package com.sloera.jvm.ref;

import java.lang.ref.WeakReference;

/**
 * @author sloera
 * @create 2020/5/3
 */
public class WeakReferenceDemo {
    public static void main(String[] args) {
        Object object = new Object();
        WeakReference<Object> weakReference = new WeakReference<>(object);
        System.out.println(object);
        System.out.println(weakReference.get());
        System.out.println("*****************");
        object = null;
        System.gc();

        System.out.println(object);
        System.out.println(weakReference.get());
    }
}
